<?php
/**
 * Created by PhpStorm.
 * User: poptser@foxmail.com
 * Date: 2018/1/30
 * Time: 14:02
 */

namespace App\Http\Controllers\WarehouseManage;
use App\Http\Controllers\ApiController;
use App\Services\Warehouse\PurchaseRequisitionService;
use App\Services\Warehouse\ValidateUserService;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Validator;

//采购入库控制器
class CaigouController extends ApiController{

    protected  $validateUserService;
    protected  $purchaseRequisitionService;
    public function __construct(PurchaseRequisitionService $purchaseRequisitionService)
    {
        $this->purchaseRequisitionService = $purchaseRequisitionService;
    }

    /**
     * 待收货和收货中的采购单列表
     * @param Request $request
     */
    public function ReceivingList(Request $request){

    }

    /**
     * 获取采购单详情（将已采购的商品显示出来）/扫描二维码打开采购单
     * @param Request $request
     */
    public function ReceivingDetails(Request $request){
        return $this->purchaseRequisitionService->ExecuteBillQueryPurchaseRequisition();

        //return $this->purchaseRequisitionService->view('CGSQ000001');
    }

    /**
     * 采购单历史记录
     * @param Request $request
     */
    public function ReceivingHistory(Request $request){

    }

    /**
     * 入库商品
     * @param Request $request goodSn货号 number操作数量 positionId仓位
     * @return string
     */
    public function StorageGoods(Request $request){
        //手动验证器
        $messages = [
            'required'    => ':attribute 必须',
            'string'    => ':attribute 必须是字符串',
            'numeric' => ':attribute 必须是纯数字',
            'min:1' => ':attribute 最小为1',
        ];
        $rules = [
            'goodSn' => 'bail|required|string|max:100',
            'number' => 'bail|required|numeric|min:1',
            'positionId' => 'bail|required|numeric',
        ];
       /* $validator = Validator::make($request->all(),$rules,$messages);
        if ($validator->fails()) {
            //验证不过，返回数据不符合原因
            $this->failed($validator->errors()->first());
        }else{


        }*/
    }
}